import axios from 'axios';
import config from './config';
import { encryptedData } from './utils';

const { authServerUrl } = config;

export default class LoginApi {

  // 登录
  static login = async ({ username, password }: { username: string, password: string }): Promise<any> => {

    const params = { username, password };
    params['password'] = await encryptedData(password) || '';

    return axios({
      method: 'POST',
      url: `${authServerUrl}/auth`,
      data: params
    });
  }

}